﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Text;

namespace Qplus.protocol
{
    public class L2C_RESP_LOGIN : InPacket 
    {
        /**
	    * 验证结果
	    */
        private int result;

        /**
	    * 用户服务器ip
	    */
        private byte[] ip;

        /**
	    * 用户服务器端口
	    */
        private int port;

        /**
	    * 用户id
	    */
        private long userID;

        /**
	    * 密钥
	    */
        private byte[] key;
        /**
         * 升级服务器地址长度
         */
        private int upgradeURLLen;
        /**
         * 升级服务器地址
         */
        private byte[] upgradeURL;

        protected override void parseBody(byte[] data, int offset, int count)
        {
            result = get1(data);
            ip = getN(data, 16);
            port = get2(data);
            userID = get4(data);
            key = getN(data, 32);
            upgradeURLLen = get1(data);
            upgradeURL = getN(data, upgradeURLLen);
        }


        public  void parseBodyT(byte[] data, int offset, int count)
        {
            result = get1(data);
            ip = getN(data, 16);
            port = get2(data);
            userID = get4(data);
            key = getN(data, 32);
            upgradeURLLen = get1(data);
            upgradeURL = getN(data, upgradeURLLen);
        }


        public int getResult()
        {
            return result;
        }

        public void setResult(int result)
        {
            this.result = result;
        }

        public String getIP()
        {
            return Encoding.UTF8.GetString(this.ip, 0, this.ip.Length);
        }

        public void setIp(byte[] ip)
        {
            this.ip = ip;
        }

        public int getPort()
        {
            return port;
        }

        public void setPort(int port)
        {
            this.port = port;
        }

        public long getUserID()
        {
            return userID;
        }

        public void setUserID(long userID)
        {
            this.userID = userID;
        }

        public byte[] getKey()
        {
            return key;
        }

        public void setKey(byte[] key)
        {
            this.key = key;
        }

        public String getUpgradeURL()
        {
            return Encoding.UTF8.GetString(upgradeURL, 0, upgradeURLLen);
        }

        public void setUpgradeURL(byte[] upgradeURL)
        {
            this.upgradeURL = upgradeURL;
        }
    }
}
